﻿#define  _CRT_SECURE_NO_WARNINGS 1
#include"SList.h"

int test01()
{
	//创建一个链表
	SLTNode* node1 = (SLTNode*)malloc(sizeof(SLTNode));
	SLTNode* node2 = (SLTNode*)malloc(sizeof(SLTNode));
	SLTNode* node3 = (SLTNode*)malloc(sizeof(SLTNode));
	SLTNode* node4 = (SLTNode*)malloc(sizeof(SLTNode));

	node1->data = 1;
	node2->data = 2;
	node3->data = 3;
	node4->data = 4;

	node1->next = node2;
	node2->next = node3;
	node3->next = node4;
	node4->next = NULL;

	SLTNode* plist = node1;
	//链表的打印
	SLTPrint(plist);
}

void test02()
{
	//创建空链表
	SLTNode* plist = NULL;
	SLTPushBack(&plist, 1);
	SLTPushBack(&plist, 2);
	SLTPushBack(&plist, 3);
	SLTPushBack(&plist, 4);
	SLTPrint(plist);

	////头插
	//SLTPrint(plist);
	//SLTPushFront(&plist, 1);
	//SLTPrint(plist);
	//SLTPushFront(&plist, 2);
	//SLTPrint(plist);
	//SLTPushFront(&plist, 3);
	//SLTPrint(plist);
	//SLTPushFront(&plist, 4);
	//SLTPrint(plist);

	//尾删
	//SLTPopBack(&plist);
	//SLTPrint(plist);
	//SLTPopBack(&plist);
	//SLTPrint(plist);
	//SLTPopBack(&plist);
	//SLTPrint(plist);
	//SLTPopBack(&plist);
	//SLTPrint(plist);
	////测试断言
	//SLTPopBack(&plist);
	//SLTPrint(plist);

	////头删
	//SLTPopFront(&plist);
	//SLTPrint(plist);
	//SLTPopFront(&plist);
	//SLTPrint(plist);
	//SLTPopFront(&plist);
	//SLTPrint(plist);
	//SLTPopFront(&plist);
	//SLTPrint(plist);
	//
	//SLTPopFront(&plist);
	//SLTPrint(plist);

	//查找
	SLTNode* pos = SLTFind(plist, 1);
	/*if (pos)
	{
		printf("找到了！\n");
	}
	else {
		printf("未找到！\n");
	}*/

	//在指定位置之前插⼊数据
	//SLTInsert(&plist, pos, 100);
	//SLTPrint(plist);
	////在指定位置之后插入数据
	//SLTInsertAfter(pos, 200);
	//SLTPrint(plist);

	////删除pos结点
	///*SLTErase(&plist, pos);
	//SLTPrint(plist);*/

	////删除pos之后的结点
	//SLTEraseAfter(pos);
	//SLTPrint(plist);

	//销毁链表
	SListDestroy(&plist);
	SLTPrint(plist);
}
int main()
{
	//test01();
	test02();
	return 0;
}